﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType="ListView">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Background" Value="Transparent" />
    </Style>
    <Style x:Key="GridViewColumnHeaderGripper" TargetType="{x:Type Thumb}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Canvas.Right" Value="-9"/>
        <Setter Property="Width" Value="18"/>
        <Setter Property="Height" Value="{Binding Path=ActualHeight,RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Background" Value="{DynamicResource ButtonBackgroundHover}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}" Background="Transparent">
                        <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type GridViewColumnHeader}" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="4,3,4,3"/>
        <Setter Property="Foreground" Value="{DynamicResource ButtonText}"/>
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                    <Grid SnapsToDevicePixels="true">
                        <Border Name="HeaderBorder" BorderThickness="0" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition MaxHeight="7"/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <Border Grid.RowSpan="2" Padding="{TemplateBinding Padding}">
                                    <ContentPresenter Name="HeaderContent"
                                    Margin="0,0,0,1"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    RecognizesAccessKey="True"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                </Border>
                            </Grid>
                        </Border>
                        <Canvas>
                            <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}" Visibility="Collapsed"/>
                        </Canvas>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource ButtonTextDisabled}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Foreground" Value="{DynamicResource ButtonTextHover}"/>
                            <Setter TargetName="HeaderBorder" Property="Background" Value="{DynamicResource ButtonBackgroundHover}"/>
                            <Setter TargetName="PART_HeaderGripper" Property="Background" Value="Transparent"/>
                            <Setter TargetName="PART_HeaderGripper" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Foreground" Value="{DynamicResource ButtonTextPressed}"/>
                            <Setter TargetName="HeaderBorder" Property="Background" Value="{DynamicResource ButtonBackgroundPressed}"/>
                            <Setter TargetName="PART_HeaderGripper" Property="Visibility" Value="Hidden"/>
                        </Trigger>
                        <Trigger Property="Height" Value="Auto">
                            <Setter Property="MinHeight" Value="20"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Static GridView.GridViewStyleKey}" TargetType="{x:Type ListView}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Background"
            Value="Transparent"/>
        <Setter Property="BorderThickness"
            Value="0"/>
        <Setter Property="Foreground"
            Value="{DynamicResource ItemText}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
            Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
            Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll"
            Value="true"/>
        <Setter Property="ScrollViewer.PanningMode"
            Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled"
            Value="False"/>
        <Setter Property="VerticalContentAlignment"
            Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListView}">
                    <Border Name="Bd"
                               BorderThickness="{TemplateBinding BorderThickness}"
                               BorderBrush="{TemplateBinding BorderBrush}"
                               Background="{TemplateBinding Background}"
                               SnapsToDevicePixels="true">
                        <ScrollViewer Padding="{TemplateBinding Padding}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsGrouping"
                     Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll"
                      Value="false"/>
                        </Trigger>
                        <Trigger Property="IsEnabled"
                     Value="false">
                            <Setter Property="Foreground"
                      Value="{DynamicResource InputTextDisabled}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ListViewItem}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush"
                Value="Transparent"/>
        <Setter Property="BorderThickness"
                Value="1"/>
        <Setter Property="Margin"
                Value="0"/>
        <Setter Property="Foreground" Value="{DynamicResource ItemText}"/>
        <Setter Property="Padding"
                Value="5,2,5,2"/>
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch"/>
        <Setter Property="VerticalContentAlignment"
                Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <Grid Background="{TemplateBinding Background}">
                        <Border Name="Selection" Visibility="Collapsed" />
                        <!-- This is used when GridView is put inside the ListView -->
                        <GridViewRowPresenter Grid.RowSpan="2"
                                              Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

                        <!-- This is used for ListView that does not use GridView -->
                        <ContentPresenter x:Name="contentPresenter"
                                          Margin="{TemplateBinding Padding}"
                                      Content="{TemplateBinding ContentControl.Content}"
                                      Visibility="Collapsed"
                                      ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
                                      ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
                                      HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
                                      VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
                                      SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="GridView.ColumnCollection" Value="{x:Null}">
                            <Setter TargetName="contentPresenter" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Selection" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="Selection" Property="Background" Value="{DynamicResource ItemBackgroundHover}"/>
                            <Setter Property="Foreground" Value="{DynamicResource ItemTextHover}" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="Selection" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="Selection" Property="Background" Value="{DynamicResource ItemBackgroundSelected}"/>
                            <Setter Property="Foreground" Value="{DynamicResource ItemTextSelected}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource ItemTextDisabled}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>